-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't highlight vars with colons as keywords #670
Conversation
Changes syntax highlighting regexp for keywords to match a colon/double-colon only at the beginning of a word, not in the middle. This allows local vars like `foo:bar` to be highlighted correctly instead of like an unknown symbol for the part before the colon and a keyword for the rest. Fixes clojure-emacs#653
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @daveliepmann , this looks like a reasonable addition!
We'd appreciate if unit tests were included.
Thanks - V
Hope these suffice. Was easier than expected, thanks for the nudge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I'll try it locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following test cases are valid Clojure so would be worth adding.
One of them would be broken, hopefully the fix won't complicate things?
:a:a ;; OK
:a:a/:a ;; the last two characters don't get keyword rendering
::a:a ;; OK
::a.a:a ;; OK
all 4 seem to work for me — the namespaced keyword path was not touched |
Looks good. Mind to share a screenshot of the rendering of those 4 cases? |
Out of curiosity - why do people use such symbols in the wild? I know the Clojure parser allows it (I doubt this was intentional, though), but it always seemed like an anti-pattern to me, that's why I never bothered much to support it in |
I started using it on a couple client projects because the lead dev (using Cursive) liked it. We had a part of the codebase which had standardized CRUD structure which cut across namespaces, so it made sense to have query and view vars side-by-side which included both object and verb, e.g. Now I mostly use it as a form of lightweight grouping, almost like a pseudo-namespace. E.g. I don't see why it would be an anti-pattern. I don't know whether it was originally intentional but it is now explicitly pointed out as legal in the reader reference. |
Thanks much! I don't have a strong opinion for either side at the moment - we can always refine things later, particularly as indeed it's an unrelated concern. Will cut a stable release. |
Thanks 🙌 |
Fixes #653
Changes syntax highlighting regexp for keywords to match a colon/double-colon only at the beginning of a word, not in the middle. This allows local vars like
foo:bar
to be highlighted correctly instead of like an unknown symbol for the part before the colon and a keyword for the rest.For my own reference, the "\<" is per https://www.gnu.org/savannah-checkouts/gnu/emacs/manual/html_node/emacs/Regexp-Backslash.html#Regexp-Backslash
Test suite
Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):
M-x checkdoc
and fixed any warnings in the code you've written.Thanks!